# Check backend dependencies script
import sys
import importlib

def check_dependency(module_name, version=None):
    try:
        module = importlib.import_module(module_name)
        if version and hasattr(module, '__version__'):
            print(f"OK: {module_name} version {module.__version__} installed")
        else:
            print(f"OK: {module_name} installed")
        return True
    except ImportError as e:
        print(f"ERROR: {module_name} not installed: {e}")
        return False

def check_dependencies():
    print("Checking backend dependencies...")
    print("=" * 50)
    
    # Required dependencies
    required_deps = [
        ("fastapi", "0.68.0"),
        ("uvicorn", "0.15.0"),
        ("sqlalchemy", "1.4.23"),
        ("pydantic", "1.8.2"),
        ("jose", "3.3.0"),
        ("passlib", "1.7.4"),
        ("multipart", "0.0.5")
    ]
    
    missing_deps = []
    
    for dep, version in required_deps:
        if not check_dependency(dep, version):
            missing_deps.append(f"{dep}=={version}")
    
    print("=" * 50)
    if missing_deps:
        print("Missing dependencies:")
        for dep in missing_deps:
            print(f"  {dep}")
        print("\nTo install missing dependencies, run:")
        print("  pip install " + " ".join(missing_deps))
    else:
        print("All dependencies are installed!")

if __name__ == "__main__":
    check_dependencies()